<template>
	<el-container>
        <el-header>
            <div class="right-panel-search">
                <div class="search-input">订单号</div>
                <el-input v-model="search.order_no" placeholder="请输入订单号" clearable @change="handleKeyDown"/>
                <el-input v-model="search.keyword" placeholder="工厂货号/SKC" clearable @change="handleKeyDown" />
                <div class="search-input">客户</div>
                    <el-select v-model="search.custom_id"  filterable placeholder="请选择客户" clearable>
                        <el-option v-for="item in keHuList" :key="item.custom_id" :label="item.apply_name" :value="item.custom_id"/>
                    </el-select>
                <el-button type="primary" icon="el-icon-search" @click="upsearch">搜索</el-button>
            </div>
        </el-header>
		<el-main class="nopadding">
			<scTable ref="table" :apiObj="apiObj" @selection-change="selectionChange" stripe remoteSort remoteFilter border :params="query" show-summary>
				<el-table-column type="selection" width="50"></el-table-column>
				<el-table-column fixed label="订单资料" align="center" width="160">
                    <el-table-column fixed label="订单号" align="center" width="160">
                        <template #default="{row}">
                            <div>{{ row.order_no }}</div>
                            <div>{{ row.create_time }}</div>
                        </template>
                    </el-table-column>
                    <el-table-column label="商品信息" fixed prop="goods" align="center" width="300">
                        <template #default="{row}">
                            <div class="shopInfo" v-if="row.goods">
                                <el-image class="img" :src="row.goods.goods_image" :preview-src-list="row.goods.goods_image_item" :initial-index="0" fit="cover" preview-teleported="true" hide-on-click-modal/>
                                <div class="right">
                                    <div>工厂货号：{{ row.factory_number }}</div>
                                    <div>批次号：{{ row.batch_number }}</div>
                                    <div>SKC：{{ row.skc }}</div>
                                    <div>商品品牌：{{ row.brand_name }}</div>
                                    <div>客户：{{ row.custom_name }}</div>
                                    <div>颜色：{{ row.goods.colour }}</div>
                                    <div v-if="row.sizeCate">商品类别：{{ row.sizeCate.title }}</div>
                                </div>
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column fixed label="下单数量" align="center" width="100">
                        <template #default="{row}">
                            <div v-for="(item,index) in row.orderDetail" :key="index">
                                <div class="textStyle">
                                    {{ item.goods_size }} - {{ item.num }}
                                </div>
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column fixed label="下单总数" prop="total_count" align="center" width="100"></el-table-column>
                </el-table-column>
				<el-table-column label="织机数据" align="center">
                    <el-table-column label="织外机" prop="zj_supplier_id" align="center" width="100" column-key="filterCreate" :filters="loom">
                        <template #default="{row}">
                            <div v-for="(item,index) in row.zj_data" :key="index">
                                <div v-for="(item1,index1) in item.zj_referred_as" :key="index1">
                                    {{ item1 }} 
                                </div> 
                                ({{item.zj_process_title}})
                                <hr v-if="index!=row.zj_data.length-1">
                            </div>
                            <!-- <div v-for="(item,index) in row.zj_referred_as" :key="index">
                                {{ item }}
                            </div> -->
                        </template>
                    </el-table-column>
                    <el-table-column label="发织日期" prop="zj_contract_date" align="center" width="100">
                        <template #default="{row}">
                            <div v-for="(item,index) in row.zj_data" :key="index">
                                {{item.zj_contract_date}}
                                <hr v-if="index!=row.zj_data.length-1">
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column label="织货期" prop="zj_due_date" align="center" width="100" column-key="filterExceed" :filters="[{ text: '已超期', value: '1' }, { text: '未超期', value: '0' }]">
                        <template #default="{row}">
                            <div v-for="(item,index) in row.zj_data" :key="index">
                                <div :style="item.zj_take_deliver_date>item.zj_due_date?'color:red':''">{{item.zj_due_date}}</div>
                                <hr v-if="index!=row.zj_data.length-1">
                            </div>
                        </template>
                        <!-- <template #default="{row}">
                            <div :style="row.zj_take_deliver_date>row.zj_due_date?'color:red':''">{{row.zj_due_date}}</div>
                        </template> -->
                    </el-table-column>
                    <el-table-column label="发织数" prop="zj_weaving_num_total" align="center" width="100">
                        <template #default="{row}">
                            <div v-for="(item,index) in row.zj_data" :key="index">
                                <div v-for="(item1,index1) in item.zj_detail" :key="index1">
                                    <div class="textStyle">
                                        {{ item1.goods_size }} - {{ item1.weaving_num }}
                                    </div>
                                </div>
                                <hr v-if="index!=row.zj_data.length-1">
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column label="织累收" prop="zj_take_over_num_total" align="center" width="100">
                        <template #default="{row}">
                            <div v-for="(item,index) in row.zj_data" :key="index">
                                <div v-for="(item1,index1) in item.zj_detail" :key="index1">
                                    <div class="textStyle">
                                        {{ item1.goods_size }} - {{ item1.take_over_num }}
                                    </div>
                                </div>
                                <hr v-if="index!=row.zj_data.length-1">
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column label="织待收" prop="zj_pending_take_num_total" align="center" width="100">
                        <template #default="{row}">
                            <div v-for="(item,index) in row.zj_data" :key="index">
                                <div v-for="(item1,index1) in item.zj_detail" :key="index1">
                                    <div class="textStyle">
                                        {{ item1.goods_size }} - {{ item1.pending_take_num }}
                                    </div>
                                </div>
                                <hr v-if="index!=row.zj_data.length-1">
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column label="最后收期" prop="zj_take_deliver_date" align="center" width="100">
                        <template #default="{row}">
                            <div v-for="(item,index) in row.zj_data" :key="index">
                                {{item.zj_take_deliver_date}}
                                <hr v-if="index!=row.zj_data.length-1">
                            </div>
                        </template>
                    </el-table-column>
				</el-table-column>
				<el-table-column label="缝挑数据" align="center">
                    <el-table-column label="缝外机" prop="ft_supplier_id" align="center" width="100" column-key="filterCreate" :filters="sewing">
                        <template #default="{row}">
                            <div v-for="(item,index) in row.ft_referred_as" :key="index">
                                {{ item }}
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column label="发缝日期" align="center" width="100">
                        <template #default="{row}">
                            {{ row.ft_contract_date }}
                        </template>
                    </el-table-column>
                    <el-table-column label="缝挑货期" align="center" width="100">
                        <template #default="{row}">
                            <div :style="row.ft_take_deliver_date>row.ft_due_date?'color:red':''">{{row.ft_due_date}}</div>
                        </template>
                    </el-table-column>
                    <el-table-column label="缝已发" prop="ft_weaving_num_total" align="center" width="100"><!-- 1 -->
                        <template #default="{row}">
                            <div v-for="(item,index) in row.ft_detail" :key="index">
                                <div class="textStyle">
                                    {{ item.goods_size }} - {{ item.weaving_num }}
                                </div>
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column label="缝累收" prop="ft_take_over_num_total" align="center" width="100">
                        <template #default="{row}">
                            <div v-for="(item,index) in row.ft_detail" :key="index">
                                <div class="textStyle">
                                    {{ item.goods_size }} - {{ item.take_over_num }}
                                </div>
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column label="缝待收" prop="ft_pending_take_num_total" align="center" width="100">
                        <template #default="{row}">
                            <div v-for="(item,index) in row.ft_detail" :key="index">
                                <div class="textStyle">
                                    {{ item.goods_size }} - {{ item.pending_take_num }}
                                </div>
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column label="最后收期" prop="ft_take_deliver_date" align="center" width="100">
                        <template #default="{row}">
                            {{ row.ft_take_deliver_date }}
                        </template>
                    </el-table-column>
				</el-table-column>
                <el-table-column label="二次工艺数据" align="center">
                    <el-table-column label="工艺外机" prop="ecgy_supplier_id" align="center" column-key="filterCreate" :filters="second" width="100">
                        <template #default="{row}">
                            <div v-for="(item,index) in row.ecgy_data" :key="index">
                                <div v-for="(item1,index1) in item.ecgy_referred_as" :key="index1">
                                    {{ item1 }} 
                                </div> 
                                ({{item.ecgy_process_title}})
                                <hr v-if="index!=row.ecgy_data.length-1">
                            </div>
                            <!-- <div v-for="(item,index) in row.ecgy_referred_as" :key="index">
                                {{ item }}
                            </div> -->
                        </template>
                    </el-table-column>
                    <el-table-column label="发工艺日期" prop="ecgy_contract_date" align="center" width="100">
                        <template #default="{row}">
                            <div v-for="(item,index) in row.ecgy_data" :key="index">
                                {{item.ecgy_contract_date}}
                                <hr v-if="index!=row.ecgy_data.length-1">
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column label="工艺货期" prop="ecgy_due_date" align="center" width="100">
                        <template #default="{row}">
                            <div v-for="(item,index) in row.ecgy_data" :key="index">
                                <div :style="item.ecgy_take_deliver_date>item.ecgy_due_date?'color:red':''">{{item.ecgy_due_date}}</div>
                                <hr v-if="index!=row.ecgy_data.length-1">
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column label="工艺已发" prop="ecgy_weaving_num_total" align="center" width="100"><!-- 1 -->
                        <template #default="{row}">
                            <div v-for="(item,index) in row.ecgy_data" :key="index">
                                <div v-for="(item1,index1) in item.ecgy_detail" :key="index1">
                                    <div class="textStyle">
                                        {{ item1.goods_size }} - {{ item1.weaving_num }}
                                    </div>
                                </div>
                                <hr v-if="index!=row.ecgy_data.length-1">
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column label="工艺待发" prop="ecgy_pending_num_total" align="center" width="100"><!-- 1 -->
                        <template #default="{row}">
                            <div v-for="(item,index) in row.ecgy_data" :key="index">
                                <div v-for="(item1,index1) in item.ecgy_detail" :key="index1">
                                    <div class="textStyle">
                                        {{ item1.goods_size }} - {{ item1.pending_num }}
                                    </div>
                                </div>
                                <hr v-if="index!=row.ecgy_data.length-1">
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column label="工艺累收" prop="ecgy_take_over_num_total" align="center" width="100">
                        <template #default="{row}">
                            <div v-for="(item,index) in row.ecgy_data" :key="index">
                                <div v-for="(item1,index1) in item.ecgy_detail" :key="index1">
                                    <div class="textStyle">
                                        {{ item1.goods_size }} - {{ item1.take_over_num }}
                                    </div>
                                </div>
                                <hr v-if="index!=row.ecgy_data.length-1">
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column label="工艺待收" prop="ecgy_pending_take_num_total" align="center" width="100">
                        <template #default="{row}">
                            <div v-for="(item,index) in row.ecgy_data" :key="index">
                                <div v-for="(item1,index1) in item.ecgy_detail" :key="index1">
                                    <div class="textStyle">
                                        {{ item1.goods_size }} - {{ item1.pending_take_num }}
                                    </div>
                                </div>
                                <hr v-if="index!=row.ecgy_data.length-1">
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column label="最后收期" prop="ecgy_take_deliver_date" align="center" width="100">
                        <template #default="{row}">
                            <div v-for="(item,index) in row.ecgy_data" :key="index">
                                {{item.ecgy_take_deliver_date}}
                                <hr v-if="index!=row.ecgy_data.length-1">
                            </div>
                        </template>
                    </el-table-column>
				</el-table-column>
                <el-table-column label="后整数据" align="center">
                    <el-table-column label="洗水" prop="hz_xs_num_total" align="center" width="100">
                        <template #default="{row}">
                            <div v-for="(item,index) in row.hz_detail.xs_num" :key="index">
                                <div class="textStyle">
                                    {{ item.goods_size }}-{{ item.num }}
                                </div>
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column label="分码" prop="hz_fm_num_total" align="center" width="100">
                        <template #default="{row}">
                            <div v-for="(item,index) in row.hz_detail.fm_num" :key="index">
                                <div class="textStyle">
                                    {{ item.goods_size }}-{{ item.num }}
                                </div>
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column label="车唛" prop="hz_cm_num_total" align="center" width="100">
                        <template #default="{row}">
                            <div v-for="(item,index) in row.hz_detail.cm_num" :key="index">
                                <div class="textStyle">
                                    {{ item.goods_size }}-{{ item.num }}
                                </div>
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column label="车唛手工" prop="hz_cmsg_num_total" align="center" width="100">
                        <template #default="{row}">
                            <div v-for="(item,index) in row.hz_detail.cmsg_num" :key="index">
                                <div class="textStyle">
                                    {{ item.goods_size }}-{{ item.num }}
                                </div>
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column label="查衫" prop="hz_cs_num_total" align="center" width="100">
                        <template #default="{row}">
                            <div v-for="(item,index) in row.hz_detail.cs_num" :key="index">
                                <div class="textStyle">
                                    {{ item.goods_size }}-{{ item.num }}
                                </div>
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column label="查衫手工" prop="hz_cssg_num_total" align="center" width="100">
                        <template #default="{row}">
                            <div v-for="(item,index) in row.hz_detail.cssg_num" :key="index">
                                <div class="textStyle">
                                    {{ item.goods_size }}-{{ item.num }}
                                </div>
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column label="烫衣" prop="hz_ty_num_total" align="center" width="100">
                        <template #default="{row}">
                            <div v-for="(item,index) in row.hz_detail.ty_num" :key="index">
                                <div class="textStyle">
                                    {{ item.goods_size }}-{{ item.num }}
                                </div>
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column label="打包" prop="hz_db_num_total" align="center" width="100">
                        <template #default="{row}">
                            <div v-for="(item,index) in row.hz_detail.db_num" :key="index">
                                <div class="textStyle">
                                    {{ item.goods_size }}-{{ item.num }}
                                </div>
                            </div>
                        </template>
                    </el-table-column>
				</el-table-column>
                <el-table-column label="成次品" prop="inventory_detail" align="center">
                    <el-table-column label="成品数" prop="wool_seed" align="center" width="100">
                        <template #default="{row}">
                            <div v-for="(item,index) in row.inventory_detail" :key="index">
                                <div class="textStyle">
                                    {{item.goods_size}} - {{ item.take_total_num }}
                                </div>
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column label="出货数" prop="wool_seed" align="center" width="100">
                        <template #default="{row}">
                            <div v-for="(item,index) in row.inventory_detail" :key="index">
                                <div class="textStyle">
                                    {{item.goods_size}} - {{ item.sell_num }}
                                </div>
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column label="库存" prop="wool_seed" align="center" width="100">
                        <template #default="{row}">
                            <div v-for="(item,index) in row.inventory_detail" :key="index">
                                <div class="textStyle">
                                    {{item.goods_size}} - {{ item.warehousing_num }}
                                </div>
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column label="次品数" prop="wool_seed" align="center" width="100">
                        <template #default="{row}">
                            <div v-for="(item,index) in row.inventory_detail" :key="index">
                                <div class="textStyle">
                                    {{item.goods_size}} - {{ item.reject_num }}
                                </div>
                            </div>
                        </template>
                    </el-table-column>
				</el-table-column>
			</scTable>
		</el-main>
	</el-container>
</template>
<script>

export default {
	name: 'user',
	data() {
		return {
			group: [],
			apiObj: this.$API.produce.orderSchedule,
			selection: [],
			search: {
				keyword: null,
				custom_id: null,
				order_no: null,
				// order_no: 'P240710022676',
			},
            keHuList: [],//客户
            loom: [],
            sewing: [],
            second: [],
		}
	},
	mounted() {
        this.getKehu()
        this.getLoom()
        this.getSewing()
        this.getSecond()
    },
	methods: {
        // 外机 -- 织机
        async getLoom() {
            var res = await this.$API.all.getProduceFilter.get({process_id:3,place:2});
			let a = []
			res.data.supplier_list.map(item => {
				a.push({
					text: item.name,
                    value: item.id,
				})
			})
			this.loom = a
		},
        // 外机 -- 缝挑
        async getSewing() {
            var res = await this.$API.all.getProduceFilter.get({process_id:4,place:2});
			let a = []
			res.data.supplier_list.map(item => {
				a.push({
					text: item.name,
                    value: item.id,
				})
			})
			this.sewing = a
		},
        // 外机 -- 二次工艺
        async getSecond() {
            var res = await this.$API.all.getProduceFilter.get({process_id:7,place:2});
			let a = []
			res.data.supplier_list.map(item => {
				a.push({
					text: item.name,
                    value: item.id,
				})
			})
			this.second = a
		},
        // 获取客户
        async getKehu(){
            var res = await this.$API.all.customer.get();
            this.keHuList = res.data;
        },
        // 回车
        handleKeyDown() {
            this.upsearch()
        },
        //搜索
		upsearch() {
			this.$refs.table.upData(this.search)
		},
	}
}
</script>

<style>
.search-input {
	width: auto;
	font-size: 14px;
}
.textStyle{
    width: 100%;
    text-align-last: justify;
    margin-right:15px
}
</style>
